-
Notifications
You must be signed in to change notification settings - Fork 55
Validate PURLs #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Validate PURLs #179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this class required , we can directly fetch the details from the hashmap ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last method of the class ensures that property is a Boolean. If fetching from a HashMap directly, the code would have to follow the fetch making it harder to read. That's why a new class was introduced.
|
||
public static <T> T getProperty(HashMap<String, Object> validationProperties, String property, T defValue) { | ||
Object object = validationProperties.get(property); | ||
if (object == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code can be optimised as follows:
object instanceof Boolean ? (Boolean) object : defValue;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but then I lose the error message. And it's important here as it would be difficult to investigate why default value was returned instead of value from HashMap. I tried to find how to check it dynamically (something linek 'object instance of T'), but generics are compile-time-only feature...
Applicable Issues
Description of the Change
Functionality validating PURLs added.
Alternate Designs
Possible Drawbacks
Sign-off
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
Signed-off-by: Roman Szturc [email protected]